#include <bits/stdc++.h>
#define int long long
using namespace std;
struct car
{
    int d,v,a;
}t[100005];
int n,T,m,L,V,p[100005],cnt;
signed main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin >> T;
    while(T--)
    {
        bool fa = 0,fb = 0;
        cnt = 0;
        int maxn = 0,ans = 0;
        cin >> n >> m >> L >> V;
        for(int i = 1;i <= n;i++)
        {
            cin >> t[i].d >> t[i].v >> t[i].a;
            if(t[i].a != 0)
            {
                fa = 1;
            }
            if(t[i].a <= 0)
            {
                fb = 1;
            }
        }
        for(int i = 1;i <= m;i++)
        {
            cin >> p[i];
            maxn = max(maxn,p[i]);
        }
        if(!fa)
        {
            for(int i = 1;i <= n;i++)
            {
                if(t[i].a == 0)
                {
                    if(t[i].v > V && t[i].d <= maxn)
                    {
                        cnt++;
                    }   
                }
                if(cnt > 0)
                {
                    ans = m - 1;
                }
                else
                {
                    ans = m;
                }
            }
        }
        if(!fb)
        {
            for(int i = 1;i <= n;i++)
            {
                long double s = ((t[i].v + V) * (V - t[i].v)) / (2 * t[i].a);
                if(s + t[i].d <= maxn)
                {
                    cnt ++;
                }
                if(cnt > 0)
                {
                    ans = m - 1;
                }
                else
                {
                    ans = m;
                }
            }
        }
        cout << cnt << " " << ans << endl;
    }
    return 0;
}